package com.wfm.leetcode.editor.cn;

import com.wfm.common.TreeNode;
import java.util.ArrayList;
import java.util.List;

public class POne12路径总和{
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public boolean hasPathSum(TreeNode root, int targetSum) {
        dfs(root,targetSum);
        return res;
    }
    boolean res = false;
    void dfs(TreeNode root,int target){
        if(root==null) return;
        if(root.left==null&&root.right==null&&target-root.val==0){
            res = true;
            return;
        }
        dfs(root.left,target-root.val);
        dfs(root.right,target-root.val);
    }
}
//leetcode submit region end(Prohibit modification and deletion)

    public static void main(String[] args) { 
        Solution solution = new POne12路径总和().new Solution();
    }
}